import request from "../utils/request";

// 示例：产品相关API
export const productAPI = {
  // 获取产品列表
  getProductList: (params?: { page: number; size: number }) => {
    return request.get("/products", { params });
  },

  // 获取产品详情
  getProductDetail: (id: number) => {
    return request.get(`/products/${id}`);
  },

  // 添加产品
  addProduct: (data: { name: string; price: number; category: string }) => {
    return request.post("/products", data);
  },

  // 更新产品
  updateProduct: (
    id: number,
    data: Partial<{ name: string; price: number }>
  ) => {
    return request.put(`/products/${id}`, data);
  },

  // 删除产品
  deleteProduct: (id: number) => {
    return request.delete(`/products/${id}`);
  },
};

// 示例：用户相关API
export const userAPI = {
  login: (data: { username: string; password: string }) => {
    return request.post("/auth/login", data);
  },

  getUserInfo: () => {
    return request.get("/users/info");
  },
};

// 可以根据业务模块继续添加其他API
